package org.pine.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 数据库数据权限枚举
 *
 * @author pine
 * @version v1.0
 * @since 2025-04-12 13:23
 */
@AllArgsConstructor
@Getter
public enum DbDataScopeEnum {

    ALL(0, "所有数据"),
    DEPT_WITH_CHILDREN(1, "部门及子部门数据"),
    DEPT(2, "本部门数据"),
    ONLY_SELF(3, "本人数据"),
    ;

    private final Integer code;
    private final String desc;

    public static DbDataScopeEnum of(Integer code) {
        return Arrays.stream(DbDataScopeEnum.values()).filter(dataScopeEnum -> Objects.equals(dataScopeEnum.code, code)).findAny().orElse(null);
    }
}
